InĀ [21]:
import os
import glob
import mne
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

# Set your data path
data_path = "/Users/jananjahed/Desktop/Bachelor's project/ds005873"

# -------------------------------
# 1. Load All TSV Annotations
# -------------------------------
def load_all_annotations(tsv_filepaths):
    annotations_list = []
    for fp in tsv_filepaths:
        ann = pd.read_csv(fp, sep='\t')
        # Add the source filename for reference
        ann['source_file'] = os.path.basename(fp)
        annotations_list.append(ann)
    if annotations_list:
        all_annotations = pd.concat(annotations_list, ignore_index=True)
        return all_annotations
    else:
        return pd.DataFrame()  # Return an empty DataFrame if none found

all_tsv_files = glob.glob(os.path.join(data_path, "**", "*_events.tsv"), recursive=True)
print(f"Found {len(all_tsv_files)} TSV files total.")
all_annotations = load_all_annotations(all_tsv_files)

# Count seizure events from annotations (assuming each row is a seizure event)
seizure_count = len(all_annotations)
print(f"Total seizure events in annotations: {seizure_count}")

# ----------------------------------
# 2. Define Epoch Creation Function
# ----------------------------------
def create_epochs(raw, annotations, tmin=-0.2, tmax=0.8):
    events = []
    event_id = {'seizure': 1, 'non-seizure': 0}
    
    # Add seizure events from annotations if available
    if not annotations.empty:
        for _, row in annotations.iterrows():
            onset = row['onset']  # Ensure your TSV has an 'onset' column
            events.append([int(onset * raw.info['sfreq']), 0, event_id['seizure']])
    
    # Add fixed-length non-seizure events (e.g., every 10 seconds)
    non_seizure_events = mne.make_fixed_length_events(raw, id=event_id['non-seizure'], duration=10)
    events.extend(non_seizure_events)
    
    events = np.array(events)
    # Set event_repeated='drop' to handle duplicate event times
    epochs = mne.Epochs(raw, events, event_id, tmin, tmax, baseline=(None, 0), preload=True,
                        event_repeated='drop')
    return epochs


# ----------------------------------
# 3. Process All EDF Files in the Dataset
# ----------------------------------
all_edf_files = glob.glob(os.path.join(data_path, "**", "*_eeg.edf"), recursive=True)
print(f"Found {len(all_edf_files)} EDF files total.")

all_epochs_list = []
for edf_file in all_edf_files:
    print(f"Processing EDF file: {edf_file}")
    
    # Load raw EEG data
    raw = mne.io.read_raw_edf(edf_file, preload=True)
    
    # Plot raw data with all channels (should be 2 channels)
    n_channels_total = len(raw.ch_names)
    raw.plot(n_channels=n_channels_total, duration=10, title=f'Raw EEG Data: {os.path.basename(edf_file)}')
    
    # Preprocess: Filter (1-40 Hz) and Notch Filter (50 Hz)
    raw_filtered = raw.copy().filter(l_freq=1, h_freq=40, method='fir', fir_window='hamming')
    raw_filtered.notch_filter(freqs=[50])
    raw_filtered.plot(n_channels=n_channels_total, duration=10, title=f'Filtered EEG Data: {os.path.basename(edf_file)}')
    
    # Find matching TSV annotation file based on EDF file base name
    base_name = os.path.basename(edf_file).replace('_eeg.edf', '')
    matching_tsv = [fp for fp in all_tsv_files if base_name in fp]
    
    if matching_tsv:
        annotations = pd.read_csv(matching_tsv[0], sep='\t')
        print(f"Using annotations from: {matching_tsv[0]}")
    else:
        print(f"No matching TSV found for {edf_file}. No seizure events will be used for this file.")
        annotations = pd.DataFrame()  # No annotations available
    
    # Create epochs using the filtered data and annotations
    epochs = create_epochs(raw_filtered, annotations)
    print(f"Created {len(epochs.events)} epochs for {os.path.basename(edf_file)}")
    all_epochs_list.append(epochs)

# ----------------------------------
# 4. Combine All Epochs
# ----------------------------------
if all_epochs_list:
    all_epochs = mne.concatenate_epochs(all_epochs_list)
    print("Total epochs created from all files:", len(all_epochs.events))
else:
    print("No epochs were created from the dataset.")

# ----------------------------------
# 5. (Optional) Plot Evoked Response from Combined Epochs
# ----------------------------------
if all_epochs_list:
    evoked = all_epochs.average()
    evoked.plot(spatial_colors=True, time_unit='s', title='Evoked Potentials from Combined Epochs')
Found 2853 TSV files total.
Total seizure events in annotations: 3664
Found 2853 EDF files total.
Processing EDF file: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-021/ses-01/eeg/sub-021_ses-01_task-szMonitoring_run-09_eeg.edf
Extracting EDF parameters from /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-021/ses-01/eeg/sub-021_ses-01_task-szMonitoring_run-09_eeg.edf...
EDF file detected
Setting channel info structure...
Creating raw.info structure...
Reading 0 ... 19222015  =      0.000 ... 75085.996 secs...
No description has been provided for this image
Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 1 - 40 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 1.00
- Lower transition bandwidth: 1.00 Hz (-6 dB cutoff frequency: 0.50 Hz)
- Upper passband edge: 40.00 Hz
- Upper transition bandwidth: 10.00 Hz (-6 dB cutoff frequency: 45.00 Hz)
- Filter length: 845 samples (3.301 s)

Filtering raw data in 1 contiguous segment
Setting up band-stop filter from 49 - 51 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandstop filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 49.38
- Lower transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 49.12 Hz)
- Upper passband edge: 50.62 Hz
- Upper transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 50.88 Hz)
- Filter length: 1691 samples (6.605 s)

No description has been provided for this image
Using annotations from: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-021/ses-01/eeg/sub-021_ses-01_task-szMonitoring_run-09_events.tsv
Multiple event values for single event times found. Keeping the first occurrence and dropping all others.
Not setting metadata
7510 matching events found
Setting baseline interval to [-0.19921875, 0.0] s
Applying baseline correction (mode: mean)
0 projection items activated
Using data from preloaded Raw for 7510 events and 257 original time points ...
1 bad epochs dropped
Created 7509 epochs for sub-021_ses-01_task-szMonitoring_run-09_eeg.edf
Processing EDF file: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-021/ses-01/eeg/sub-021_ses-01_task-szMonitoring_run-08_eeg.edf
Extracting EDF parameters from /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-021/ses-01/eeg/sub-021_ses-01_task-szMonitoring_run-08_eeg.edf...
EDF file detected
Setting channel info structure...
Creating raw.info structure...
Reading 0 ... 19253247  =      0.000 ... 75207.996 secs...
No description has been provided for this image
Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 1 - 40 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 1.00
- Lower transition bandwidth: 1.00 Hz (-6 dB cutoff frequency: 0.50 Hz)
- Upper passband edge: 40.00 Hz
- Upper transition bandwidth: 10.00 Hz (-6 dB cutoff frequency: 45.00 Hz)
- Filter length: 845 samples (3.301 s)

Filtering raw data in 1 contiguous segment
Setting up band-stop filter from 49 - 51 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandstop filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 49.38
- Lower transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 49.12 Hz)
- Upper passband edge: 50.62 Hz
- Upper transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 50.88 Hz)
- Filter length: 1691 samples (6.605 s)

No description has been provided for this image
Using annotations from: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-021/ses-01/eeg/sub-021_ses-01_task-szMonitoring_run-08_events.tsv
Not setting metadata
7522 matching events found
Setting baseline interval to [-0.19921875, 0.0] s
Applying baseline correction (mode: mean)
0 projection items activated
Using data from preloaded Raw for 7522 events and 257 original time points ...
/var/folders/s6/5tcrcv3n2mb5m18jfn2czp_r0000gn/T/ipykernel_5102/1141197103.py:54: RuntimeWarning: The events passed to the Epochs constructor are not chronologically ordered.
  epochs = mne.Epochs(raw, events, event_id, tmin, tmax, baseline=(None, 0), preload=True,
1 bad epochs dropped
Created 7521 epochs for sub-021_ses-01_task-szMonitoring_run-08_eeg.edf
Processing EDF file: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-021/ses-01/eeg/sub-021_ses-01_task-szMonitoring_run-01_eeg.edf
Extracting EDF parameters from /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-021/ses-01/eeg/sub-021_ses-01_task-szMonitoring_run-01_eeg.edf...
EDF file detected
Setting channel info structure...
Creating raw.info structure...
Reading 0 ... 3504383  =      0.000 ... 13688.996 secs...
No description has been provided for this image
Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 1 - 40 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 1.00
- Lower transition bandwidth: 1.00 Hz (-6 dB cutoff frequency: 0.50 Hz)
- Upper passband edge: 40.00 Hz
- Upper transition bandwidth: 10.00 Hz (-6 dB cutoff frequency: 45.00 Hz)
- Filter length: 845 samples (3.301 s)

Filtering raw data in 1 contiguous segment
Setting up band-stop filter from 49 - 51 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandstop filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 49.38
- Lower transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 49.12 Hz)
- Upper passband edge: 50.62 Hz
- Upper transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 50.88 Hz)
- Filter length: 1691 samples (6.605 s)

No description has been provided for this image
Using annotations from: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-021/ses-01/eeg/sub-021_ses-01_task-szMonitoring_run-01_events.tsv
Not setting metadata
1369 matching events found
Setting baseline interval to [-0.19921875, 0.0] s
Applying baseline correction (mode: mean)
0 projection items activated
Using data from preloaded Raw for 1369 events and 257 original time points ...
1 bad epochs dropped
Created 1368 epochs for sub-021_ses-01_task-szMonitoring_run-01_eeg.edf
Processing EDF file: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-021/ses-01/eeg/sub-021_ses-01_task-szMonitoring_run-03_eeg.edf
Extracting EDF parameters from /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-021/ses-01/eeg/sub-021_ses-01_task-szMonitoring_run-03_eeg.edf...
EDF file detected
Setting channel info structure...
Creating raw.info structure...
Reading 0 ... 2582527  =      0.000 ... 10087.996 secs...
/var/folders/s6/5tcrcv3n2mb5m18jfn2czp_r0000gn/T/ipykernel_5102/1141197103.py:54: RuntimeWarning: The events passed to the Epochs constructor are not chronologically ordered.
  epochs = mne.Epochs(raw, events, event_id, tmin, tmax, baseline=(None, 0), preload=True,
No description has been provided for this image
Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 1 - 40 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 1.00
- Lower transition bandwidth: 1.00 Hz (-6 dB cutoff frequency: 0.50 Hz)
- Upper passband edge: 40.00 Hz
- Upper transition bandwidth: 10.00 Hz (-6 dB cutoff frequency: 45.00 Hz)
- Filter length: 845 samples (3.301 s)

Filtering raw data in 1 contiguous segment
Setting up band-stop filter from 49 - 51 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandstop filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 49.38
- Lower transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 49.12 Hz)
- Upper passband edge: 50.62 Hz
- Upper transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 50.88 Hz)
- Filter length: 1691 samples (6.605 s)

No description has been provided for this image
Using annotations from: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-021/ses-01/eeg/sub-021_ses-01_task-szMonitoring_run-03_events.tsv
Multiple event values for single event times found. Keeping the first occurrence and dropping all others.
Not setting metadata
1008 matching events found
Setting baseline interval to [-0.19921875, 0.0] s
Applying baseline correction (mode: mean)
0 projection items activated
Using data from preloaded Raw for 1008 events and 257 original time points ...
1 bad epochs dropped
Created 1007 epochs for sub-021_ses-01_task-szMonitoring_run-03_eeg.edf
Processing EDF file: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-021/ses-01/eeg/sub-021_ses-01_task-szMonitoring_run-02_eeg.edf
Extracting EDF parameters from /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-021/ses-01/eeg/sub-021_ses-01_task-szMonitoring_run-02_eeg.edf...
EDF file detected
Setting channel info structure...
Creating raw.info structure...
Reading 0 ... 15119359  =      0.000 ... 59059.996 secs...
No description has been provided for this image
Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 1 - 40 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 1.00
- Lower transition bandwidth: 1.00 Hz (-6 dB cutoff frequency: 0.50 Hz)
- Upper passband edge: 40.00 Hz
- Upper transition bandwidth: 10.00 Hz (-6 dB cutoff frequency: 45.00 Hz)
- Filter length: 845 samples (3.301 s)

Filtering raw data in 1 contiguous segment
Setting up band-stop filter from 49 - 51 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandstop filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 49.38
- Lower transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 49.12 Hz)
- Upper passband edge: 50.62 Hz
- Upper transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 50.88 Hz)
- Filter length: 1691 samples (6.605 s)

No description has been provided for this image
Using annotations from: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-021/ses-01/eeg/sub-021_ses-01_task-szMonitoring_run-02_events.tsv
Multiple event values for single event times found. Keeping the first occurrence and dropping all others.
Not setting metadata
5906 matching events found
Setting baseline interval to [-0.19921875, 0.0] s
Applying baseline correction (mode: mean)
0 projection items activated
Using data from preloaded Raw for 5906 events and 257 original time points ...
1 bad epochs dropped
Created 5905 epochs for sub-021_ses-01_task-szMonitoring_run-02_eeg.edf
Processing EDF file: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-021/ses-01/eeg/sub-021_ses-01_task-szMonitoring_run-07_eeg.edf
Extracting EDF parameters from /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-021/ses-01/eeg/sub-021_ses-01_task-szMonitoring_run-07_eeg.edf...
EDF file detected
Setting channel info structure...
Creating raw.info structure...
Reading 0 ... 2556671  =      0.000 ...  9986.996 secs...
No description has been provided for this image
Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 1 - 40 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 1.00
- Lower transition bandwidth: 1.00 Hz (-6 dB cutoff frequency: 0.50 Hz)
- Upper passband edge: 40.00 Hz
- Upper transition bandwidth: 10.00 Hz (-6 dB cutoff frequency: 45.00 Hz)
- Filter length: 845 samples (3.301 s)

Filtering raw data in 1 contiguous segment
Setting up band-stop filter from 49 - 51 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandstop filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 49.38
- Lower transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 49.12 Hz)
- Upper passband edge: 50.62 Hz
- Upper transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 50.88 Hz)
- Filter length: 1691 samples (6.605 s)

No description has been provided for this image
Using annotations from: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-021/ses-01/eeg/sub-021_ses-01_task-szMonitoring_run-07_events.tsv
Multiple event values for single event times found. Keeping the first occurrence and dropping all others.
Not setting metadata
998 matching events found
Setting baseline interval to [-0.19921875, 0.0] s
Applying baseline correction (mode: mean)
0 projection items activated
Using data from preloaded Raw for 998 events and 257 original time points ...
1 bad epochs dropped
Created 997 epochs for sub-021_ses-01_task-szMonitoring_run-07_eeg.edf
Processing EDF file: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-021/ses-01/eeg/sub-021_ses-01_task-szMonitoring_run-06_eeg.edf
Extracting EDF parameters from /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-021/ses-01/eeg/sub-021_ses-01_task-szMonitoring_run-06_eeg.edf...
EDF file detected
Setting channel info structure...
Creating raw.info structure...
Reading 0 ... 19847935  =      0.000 ... 77530.996 secs...
No description has been provided for this image
Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 1 - 40 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 1.00
- Lower transition bandwidth: 1.00 Hz (-6 dB cutoff frequency: 0.50 Hz)
- Upper passband edge: 40.00 Hz
- Upper transition bandwidth: 10.00 Hz (-6 dB cutoff frequency: 45.00 Hz)
- Filter length: 845 samples (3.301 s)

Filtering raw data in 1 contiguous segment
Setting up band-stop filter from 49 - 51 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandstop filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 49.38
- Lower transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 49.12 Hz)
- Upper passband edge: 50.62 Hz
- Upper transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 50.88 Hz)
- Filter length: 1691 samples (6.605 s)

No description has been provided for this image
Using annotations from: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-021/ses-01/eeg/sub-021_ses-01_task-szMonitoring_run-06_events.tsv
Not setting metadata
7756 matching events found
Setting baseline interval to [-0.19921875, 0.0] s
Applying baseline correction (mode: mean)
0 projection items activated
Using data from preloaded Raw for 7756 events and 257 original time points ...
/var/folders/s6/5tcrcv3n2mb5m18jfn2czp_r0000gn/T/ipykernel_5102/1141197103.py:54: RuntimeWarning: The events passed to the Epochs constructor are not chronologically ordered.
  epochs = mne.Epochs(raw, events, event_id, tmin, tmax, baseline=(None, 0), preload=True,
1 bad epochs dropped
Created 7755 epochs for sub-021_ses-01_task-szMonitoring_run-06_eeg.edf
Processing EDF file: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-021/ses-01/eeg/sub-021_ses-01_task-szMonitoring_run-04_eeg.edf
Extracting EDF parameters from /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-021/ses-01/eeg/sub-021_ses-01_task-szMonitoring_run-04_eeg.edf...
EDF file detected
Setting channel info structure...
Creating raw.info structure...
Reading 0 ... 19109375  =      0.000 ... 74645.996 secs...
No description has been provided for this image
Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 1 - 40 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 1.00
- Lower transition bandwidth: 1.00 Hz (-6 dB cutoff frequency: 0.50 Hz)
- Upper passband edge: 40.00 Hz
- Upper transition bandwidth: 10.00 Hz (-6 dB cutoff frequency: 45.00 Hz)
- Filter length: 845 samples (3.301 s)

Filtering raw data in 1 contiguous segment
Setting up band-stop filter from 49 - 51 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandstop filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 49.38
- Lower transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 49.12 Hz)
- Upper passband edge: 50.62 Hz
- Upper transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 50.88 Hz)
- Filter length: 1691 samples (6.605 s)

No description has been provided for this image
Using annotations from: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-021/ses-01/eeg/sub-021_ses-01_task-szMonitoring_run-04_events.tsv
Multiple event values for single event times found. Keeping the first occurrence and dropping all others.
Not setting metadata
7467 matching events found
Setting baseline interval to [-0.19921875, 0.0] s
Applying baseline correction (mode: mean)
0 projection items activated
Using data from preloaded Raw for 7467 events and 257 original time points ...
1 bad epochs dropped
Created 7466 epochs for sub-021_ses-01_task-szMonitoring_run-04_eeg.edf
Processing EDF file: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-021/ses-01/eeg/sub-021_ses-01_task-szMonitoring_run-05_eeg.edf
Extracting EDF parameters from /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-021/ses-01/eeg/sub-021_ses-01_task-szMonitoring_run-05_eeg.edf...
EDF file detected
Setting channel info structure...
Creating raw.info structure...
Reading 0 ... 1812735  =      0.000 ...  7080.996 secs...
No description has been provided for this image
Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 1 - 40 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 1.00
- Lower transition bandwidth: 1.00 Hz (-6 dB cutoff frequency: 0.50 Hz)
- Upper passband edge: 40.00 Hz
- Upper transition bandwidth: 10.00 Hz (-6 dB cutoff frequency: 45.00 Hz)
- Filter length: 845 samples (3.301 s)

Filtering raw data in 1 contiguous segment
Setting up band-stop filter from 49 - 51 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandstop filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 49.38
- Lower transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 49.12 Hz)
- Upper passband edge: 50.62 Hz
- Upper transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 50.88 Hz)
- Filter length: 1691 samples (6.605 s)

No description has been provided for this image
Using annotations from: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-021/ses-01/eeg/sub-021_ses-01_task-szMonitoring_run-05_events.tsv
Multiple event values for single event times found. Keeping the first occurrence and dropping all others.
Not setting metadata
708 matching events found
Setting baseline interval to [-0.19921875, 0.0] s
Applying baseline correction (mode: mean)
0 projection items activated
Using data from preloaded Raw for 708 events and 257 original time points ...
1 bad epochs dropped
Created 707 epochs for sub-021_ses-01_task-szMonitoring_run-05_eeg.edf
Processing EDF file: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-026/ses-01/eeg/sub-026_ses-01_task-szMonitoring_run-03_eeg.edf
Extracting EDF parameters from /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-026/ses-01/eeg/sub-026_ses-01_task-szMonitoring_run-03_eeg.edf...
EDF file detected
Setting channel info structure...
Creating raw.info structure...
Reading 0 ... 3352063  =      0.000 ... 13093.996 secs...
No description has been provided for this image
Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 1 - 40 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 1.00
- Lower transition bandwidth: 1.00 Hz (-6 dB cutoff frequency: 0.50 Hz)
- Upper passband edge: 40.00 Hz
- Upper transition bandwidth: 10.00 Hz (-6 dB cutoff frequency: 45.00 Hz)
- Filter length: 845 samples (3.301 s)

Filtering raw data in 1 contiguous segment
Setting up band-stop filter from 49 - 51 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandstop filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 49.38
- Lower transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 49.12 Hz)
- Upper passband edge: 50.62 Hz
- Upper transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 50.88 Hz)
- Filter length: 1691 samples (6.605 s)

No description has been provided for this image
Using annotations from: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-026/ses-01/eeg/sub-026_ses-01_task-szMonitoring_run-03_events.tsv
Not setting metadata
1310 matching events found
Setting baseline interval to [-0.19921875, 0.0] s
Applying baseline correction (mode: mean)
0 projection items activated
Using data from preloaded Raw for 1310 events and 257 original time points ...
1 bad epochs dropped
Created 1309 epochs for sub-026_ses-01_task-szMonitoring_run-03_eeg.edf
Processing EDF file: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-026/ses-01/eeg/sub-026_ses-01_task-szMonitoring_run-02_eeg.edf
Extracting EDF parameters from /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-026/ses-01/eeg/sub-026_ses-01_task-szMonitoring_run-02_eeg.edf...
EDF file detected
Setting channel info structure...
Creating raw.info structure...
Reading 0 ... 17743615  =      0.000 ... 69310.996 secs...
/var/folders/s6/5tcrcv3n2mb5m18jfn2czp_r0000gn/T/ipykernel_5102/1141197103.py:54: RuntimeWarning: The events passed to the Epochs constructor are not chronologically ordered.
  epochs = mne.Epochs(raw, events, event_id, tmin, tmax, baseline=(None, 0), preload=True,
No description has been provided for this image
Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 1 - 40 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 1.00
- Lower transition bandwidth: 1.00 Hz (-6 dB cutoff frequency: 0.50 Hz)
- Upper passband edge: 40.00 Hz
- Upper transition bandwidth: 10.00 Hz (-6 dB cutoff frequency: 45.00 Hz)
- Filter length: 845 samples (3.301 s)

Filtering raw data in 1 contiguous segment
Setting up band-stop filter from 49 - 51 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandstop filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 49.38
- Lower transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 49.12 Hz)
- Upper passband edge: 50.62 Hz
- Upper transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 50.88 Hz)
- Filter length: 1691 samples (6.605 s)

No description has been provided for this image
Using annotations from: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-026/ses-01/eeg/sub-026_ses-01_task-szMonitoring_run-02_events.tsv
Multiple event values for single event times found. Keeping the first occurrence and dropping all others.
Not setting metadata
6931 matching events found
Setting baseline interval to [-0.19921875, 0.0] s
Applying baseline correction (mode: mean)
0 projection items activated
Using data from preloaded Raw for 6931 events and 257 original time points ...
1 bad epochs dropped
Created 6930 epochs for sub-026_ses-01_task-szMonitoring_run-02_eeg.edf
Processing EDF file: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-026/ses-01/eeg/sub-026_ses-01_task-szMonitoring_run-09_eeg.edf
Extracting EDF parameters from /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-026/ses-01/eeg/sub-026_ses-01_task-szMonitoring_run-09_eeg.edf...
EDF file detected
Setting channel info structure...
Creating raw.info structure...
Reading 0 ... 18558207  =      0.000 ... 72492.996 secs...
No description has been provided for this image
Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 1 - 40 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 1.00
- Lower transition bandwidth: 1.00 Hz (-6 dB cutoff frequency: 0.50 Hz)
- Upper passband edge: 40.00 Hz
- Upper transition bandwidth: 10.00 Hz (-6 dB cutoff frequency: 45.00 Hz)
- Filter length: 845 samples (3.301 s)

Filtering raw data in 1 contiguous segment
Setting up band-stop filter from 49 - 51 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandstop filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 49.38
- Lower transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 49.12 Hz)
- Upper passband edge: 50.62 Hz
- Upper transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 50.88 Hz)
- Filter length: 1691 samples (6.605 s)

No description has been provided for this image
Using annotations from: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-026/ses-01/eeg/sub-026_ses-01_task-szMonitoring_run-09_events.tsv
Multiple event values for single event times found. Keeping the first occurrence and dropping all others.
Not setting metadata
7249 matching events found
Setting baseline interval to [-0.19921875, 0.0] s
Applying baseline correction (mode: mean)
0 projection items activated
Using data from preloaded Raw for 7249 events and 257 original time points ...
1 bad epochs dropped
Created 7248 epochs for sub-026_ses-01_task-szMonitoring_run-09_eeg.edf
Processing EDF file: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-026/ses-01/eeg/sub-026_ses-01_task-szMonitoring_run-01_eeg.edf
Extracting EDF parameters from /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-026/ses-01/eeg/sub-026_ses-01_task-szMonitoring_run-01_eeg.edf...
EDF file detected
Setting channel info structure...
Creating raw.info structure...
Reading 0 ... 705791  =      0.000 ...  2756.996 secs...
No description has been provided for this image
Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 1 - 40 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 1.00
- Lower transition bandwidth: 1.00 Hz (-6 dB cutoff frequency: 0.50 Hz)
- Upper passband edge: 40.00 Hz
- Upper transition bandwidth: 10.00 Hz (-6 dB cutoff frequency: 45.00 Hz)
- Filter length: 845 samples (3.301 s)

Filtering raw data in 1 contiguous segment
Setting up band-stop filter from 49 - 51 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandstop filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 49.38
- Lower transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 49.12 Hz)
- Upper passband edge: 50.62 Hz
- Upper transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 50.88 Hz)
- Filter length: 1691 samples (6.605 s)

No description has been provided for this image
Using annotations from: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-026/ses-01/eeg/sub-026_ses-01_task-szMonitoring_run-01_events.tsv
Not setting metadata
276 matching events found
Setting baseline interval to [-0.19921875, 0.0] s
Applying baseline correction (mode: mean)
0 projection items activated
Using data from preloaded Raw for 276 events and 257 original time points ...
1 bad epochs dropped
Created 275 epochs for sub-026_ses-01_task-szMonitoring_run-01_eeg.edf
Processing EDF file: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-026/ses-01/eeg/sub-026_ses-01_task-szMonitoring_run-08_eeg.edf
Extracting EDF parameters from /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-026/ses-01/eeg/sub-026_ses-01_task-szMonitoring_run-08_eeg.edf...
EDF file detected
Setting channel info structure...
Creating raw.info structure...
Reading 0 ... 3948287  =      0.000 ... 15422.996 secs...
/var/folders/s6/5tcrcv3n2mb5m18jfn2czp_r0000gn/T/ipykernel_5102/1141197103.py:54: RuntimeWarning: The events passed to the Epochs constructor are not chronologically ordered.
  epochs = mne.Epochs(raw, events, event_id, tmin, tmax, baseline=(None, 0), preload=True,
No description has been provided for this image
Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 1 - 40 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 1.00
- Lower transition bandwidth: 1.00 Hz (-6 dB cutoff frequency: 0.50 Hz)
- Upper passband edge: 40.00 Hz
- Upper transition bandwidth: 10.00 Hz (-6 dB cutoff frequency: 45.00 Hz)
- Filter length: 845 samples (3.301 s)

Filtering raw data in 1 contiguous segment
Setting up band-stop filter from 49 - 51 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandstop filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 49.38
- Lower transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 49.12 Hz)
- Upper passband edge: 50.62 Hz
- Upper transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 50.88 Hz)
- Filter length: 1691 samples (6.605 s)

No description has been provided for this image
Using annotations from: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-026/ses-01/eeg/sub-026_ses-01_task-szMonitoring_run-08_events.tsv
Multiple event values for single event times found. Keeping the first occurrence and dropping all others.
Not setting metadata
1542 matching events found
Setting baseline interval to [-0.19921875, 0.0] s
Applying baseline correction (mode: mean)
0 projection items activated
Using data from preloaded Raw for 1542 events and 257 original time points ...
1 bad epochs dropped
Created 1541 epochs for sub-026_ses-01_task-szMonitoring_run-08_eeg.edf
Processing EDF file: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-026/ses-01/eeg/sub-026_ses-01_task-szMonitoring_run-04_eeg.edf
Extracting EDF parameters from /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-026/ses-01/eeg/sub-026_ses-01_task-szMonitoring_run-04_eeg.edf...
EDF file detected
Setting channel info structure...
Creating raw.info structure...
Reading 0 ... 18638335  =      0.000 ... 72805.996 secs...
No description has been provided for this image
Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 1 - 40 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 1.00
- Lower transition bandwidth: 1.00 Hz (-6 dB cutoff frequency: 0.50 Hz)
- Upper passband edge: 40.00 Hz
- Upper transition bandwidth: 10.00 Hz (-6 dB cutoff frequency: 45.00 Hz)
- Filter length: 845 samples (3.301 s)

Filtering raw data in 1 contiguous segment
Setting up band-stop filter from 49 - 51 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandstop filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 49.38
- Lower transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 49.12 Hz)
- Upper passband edge: 50.62 Hz
- Upper transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 50.88 Hz)
- Filter length: 1691 samples (6.605 s)

No description has been provided for this image
Using annotations from: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-026/ses-01/eeg/sub-026_ses-01_task-szMonitoring_run-04_events.tsv
Not setting metadata
7282 matching events found
Setting baseline interval to [-0.19921875, 0.0] s
Applying baseline correction (mode: mean)
0 projection items activated
Using data from preloaded Raw for 7282 events and 257 original time points ...
/var/folders/s6/5tcrcv3n2mb5m18jfn2czp_r0000gn/T/ipykernel_5102/1141197103.py:54: RuntimeWarning: The events passed to the Epochs constructor are not chronologically ordered.
  epochs = mne.Epochs(raw, events, event_id, tmin, tmax, baseline=(None, 0), preload=True,
1 bad epochs dropped
Created 7281 epochs for sub-026_ses-01_task-szMonitoring_run-04_eeg.edf
Processing EDF file: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-026/ses-01/eeg/sub-026_ses-01_task-szMonitoring_run-05_eeg.edf
Extracting EDF parameters from /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-026/ses-01/eeg/sub-026_ses-01_task-szMonitoring_run-05_eeg.edf...
EDF file detected
Setting channel info structure...
Creating raw.info structure...
Reading 0 ... 3580159  =      0.000 ... 13984.996 secs...
No description has been provided for this image
Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 1 - 40 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 1.00
- Lower transition bandwidth: 1.00 Hz (-6 dB cutoff frequency: 0.50 Hz)
- Upper passband edge: 40.00 Hz
- Upper transition bandwidth: 10.00 Hz (-6 dB cutoff frequency: 45.00 Hz)
- Filter length: 845 samples (3.301 s)

Filtering raw data in 1 contiguous segment
Setting up band-stop filter from 49 - 51 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandstop filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 49.38
- Lower transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 49.12 Hz)
- Upper passband edge: 50.62 Hz
- Upper transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 50.88 Hz)
- Filter length: 1691 samples (6.605 s)

No description has been provided for this image
Using annotations from: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-026/ses-01/eeg/sub-026_ses-01_task-szMonitoring_run-05_events.tsv
Multiple event values for single event times found. Keeping the first occurrence and dropping all others.
Not setting metadata
1398 matching events found
Setting baseline interval to [-0.19921875, 0.0] s
Applying baseline correction (mode: mean)
0 projection items activated
Using data from preloaded Raw for 1398 events and 257 original time points ...
1 bad epochs dropped
Created 1397 epochs for sub-026_ses-01_task-szMonitoring_run-05_eeg.edf
Processing EDF file: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-026/ses-01/eeg/sub-026_ses-01_task-szMonitoring_run-07_eeg.edf
Extracting EDF parameters from /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-026/ses-01/eeg/sub-026_ses-01_task-szMonitoring_run-07_eeg.edf...
EDF file detected
Setting channel info structure...
Creating raw.info structure...
Reading 0 ... 15623423  =      0.000 ... 61028.996 secs...
No description has been provided for this image
Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 1 - 40 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 1.00
- Lower transition bandwidth: 1.00 Hz (-6 dB cutoff frequency: 0.50 Hz)
- Upper passband edge: 40.00 Hz
- Upper transition bandwidth: 10.00 Hz (-6 dB cutoff frequency: 45.00 Hz)
- Filter length: 845 samples (3.301 s)

Filtering raw data in 1 contiguous segment
Setting up band-stop filter from 49 - 51 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandstop filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 49.38
- Lower transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 49.12 Hz)
- Upper passband edge: 50.62 Hz
- Upper transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 50.88 Hz)
- Filter length: 1691 samples (6.605 s)

No description has been provided for this image
Using annotations from: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-026/ses-01/eeg/sub-026_ses-01_task-szMonitoring_run-07_events.tsv
Multiple event values for single event times found. Keeping the first occurrence and dropping all others.
Not setting metadata
6102 matching events found
Setting baseline interval to [-0.19921875, 0.0] s
Applying baseline correction (mode: mean)
0 projection items activated
Using data from preloaded Raw for 6102 events and 257 original time points ...
1 bad epochs dropped
Created 6101 epochs for sub-026_ses-01_task-szMonitoring_run-07_eeg.edf
Processing EDF file: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-026/ses-01/eeg/sub-026_ses-01_task-szMonitoring_run-06_eeg.edf
Extracting EDF parameters from /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-026/ses-01/eeg/sub-026_ses-01_task-szMonitoring_run-06_eeg.edf...
EDF file detected
Setting channel info structure...
Creating raw.info structure...
Reading 0 ... 1293055  =      0.000 ...  5050.996 secs...
No description has been provided for this image
Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 1 - 40 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 1.00
- Lower transition bandwidth: 1.00 Hz (-6 dB cutoff frequency: 0.50 Hz)
- Upper passband edge: 40.00 Hz
- Upper transition bandwidth: 10.00 Hz (-6 dB cutoff frequency: 45.00 Hz)
- Filter length: 845 samples (3.301 s)

Filtering raw data in 1 contiguous segment
Setting up band-stop filter from 49 - 51 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandstop filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 49.38
- Lower transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 49.12 Hz)
- Upper passband edge: 50.62 Hz
- Upper transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 50.88 Hz)
- Filter length: 1691 samples (6.605 s)

No description has been provided for this image
Using annotations from: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-026/ses-01/eeg/sub-026_ses-01_task-szMonitoring_run-06_events.tsv
Not setting metadata
506 matching events found
Setting baseline interval to [-0.19921875, 0.0] s
Applying baseline correction (mode: mean)
0 projection items activated
Using data from preloaded Raw for 506 events and 257 original time points ...
1 bad epochs dropped
Created 505 epochs for sub-026_ses-01_task-szMonitoring_run-06_eeg.edf
Processing EDF file: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-019/ses-01/eeg/sub-019_ses-01_task-szMonitoring_run-08_eeg.edf
Extracting EDF parameters from /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-019/ses-01/eeg/sub-019_ses-01_task-szMonitoring_run-08_eeg.edf...
EDF file detected
Setting channel info structure...
Creating raw.info structure...
Reading 0 ... 2151167  =      0.000 ...  8402.996 secs...
/var/folders/s6/5tcrcv3n2mb5m18jfn2czp_r0000gn/T/ipykernel_5102/1141197103.py:54: RuntimeWarning: The events passed to the Epochs constructor are not chronologically ordered.
  epochs = mne.Epochs(raw, events, event_id, tmin, tmax, baseline=(None, 0), preload=True,
No description has been provided for this image
Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 1 - 40 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 1.00
- Lower transition bandwidth: 1.00 Hz (-6 dB cutoff frequency: 0.50 Hz)
- Upper passband edge: 40.00 Hz
- Upper transition bandwidth: 10.00 Hz (-6 dB cutoff frequency: 45.00 Hz)
- Filter length: 845 samples (3.301 s)

Filtering raw data in 1 contiguous segment
Setting up band-stop filter from 49 - 51 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandstop filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 49.38
- Lower transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 49.12 Hz)
- Upper passband edge: 50.62 Hz
- Upper transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 50.88 Hz)
- Filter length: 1691 samples (6.605 s)

No description has been provided for this image
Using annotations from: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-019/ses-01/eeg/sub-019_ses-01_task-szMonitoring_run-08_events.tsv
Multiple event values for single event times found. Keeping the first occurrence and dropping all others.
Not setting metadata
840 matching events found
Setting baseline interval to [-0.19921875, 0.0] s
Applying baseline correction (mode: mean)
0 projection items activated
Using data from preloaded Raw for 840 events and 257 original time points ...
1 bad epochs dropped
Created 839 epochs for sub-019_ses-01_task-szMonitoring_run-08_eeg.edf
Processing EDF file: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-019/ses-01/eeg/sub-019_ses-01_task-szMonitoring_run-01_eeg.edf
Extracting EDF parameters from /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-019/ses-01/eeg/sub-019_ses-01_task-szMonitoring_run-01_eeg.edf...
EDF file detected
Setting channel info structure...
Creating raw.info structure...
Reading 0 ... 19570687  =      0.000 ... 76447.996 secs...
No description has been provided for this image
Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 1 - 40 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 1.00
- Lower transition bandwidth: 1.00 Hz (-6 dB cutoff frequency: 0.50 Hz)
- Upper passband edge: 40.00 Hz
- Upper transition bandwidth: 10.00 Hz (-6 dB cutoff frequency: 45.00 Hz)
- Filter length: 845 samples (3.301 s)

Filtering raw data in 1 contiguous segment
Setting up band-stop filter from 49 - 51 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandstop filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 49.38
- Lower transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 49.12 Hz)
- Upper passband edge: 50.62 Hz
- Upper transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 50.88 Hz)
- Filter length: 1691 samples (6.605 s)

No description has been provided for this image
Using annotations from: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-019/ses-01/eeg/sub-019_ses-01_task-szMonitoring_run-01_events.tsv
Multiple event values for single event times found. Keeping the first occurrence and dropping all others.
Not setting metadata
7644 matching events found
Setting baseline interval to [-0.19921875, 0.0] s
Applying baseline correction (mode: mean)
0 projection items activated
Using data from preloaded Raw for 7644 events and 257 original time points ...
1 bad epochs dropped
Created 7643 epochs for sub-019_ses-01_task-szMonitoring_run-01_eeg.edf
Processing EDF file: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-019/ses-01/eeg/sub-019_ses-01_task-szMonitoring_run-09_eeg.edf
Extracting EDF parameters from /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-019/ses-01/eeg/sub-019_ses-01_task-szMonitoring_run-09_eeg.edf...
EDF file detected
Setting channel info structure...
Creating raw.info structure...
Reading 0 ... 19474943  =      0.000 ... 76073.996 secs...
No description has been provided for this image
Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 1 - 40 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 1.00
- Lower transition bandwidth: 1.00 Hz (-6 dB cutoff frequency: 0.50 Hz)
- Upper passband edge: 40.00 Hz
- Upper transition bandwidth: 10.00 Hz (-6 dB cutoff frequency: 45.00 Hz)
- Filter length: 845 samples (3.301 s)

Filtering raw data in 1 contiguous segment
Setting up band-stop filter from 49 - 51 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandstop filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 49.38
- Lower transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 49.12 Hz)
- Upper passband edge: 50.62 Hz
- Upper transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 50.88 Hz)
- Filter length: 1691 samples (6.605 s)

No description has been provided for this image
Using annotations from: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-019/ses-01/eeg/sub-019_ses-01_task-szMonitoring_run-09_events.tsv
Multiple event values for single event times found. Keeping the first occurrence and dropping all others.
Not setting metadata
7607 matching events found
Setting baseline interval to [-0.19921875, 0.0] s
Applying baseline correction (mode: mean)
0 projection items activated
Using data from preloaded Raw for 7607 events and 257 original time points ...
1 bad epochs dropped
Created 7606 epochs for sub-019_ses-01_task-szMonitoring_run-09_eeg.edf
Processing EDF file: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-019/ses-01/eeg/sub-019_ses-01_task-szMonitoring_run-02_eeg.edf
Extracting EDF parameters from /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-019/ses-01/eeg/sub-019_ses-01_task-szMonitoring_run-02_eeg.edf...
EDF file detected
Setting channel info structure...
Creating raw.info structure...
Reading 0 ... 2353919  =      0.000 ...  9194.996 secs...
No description has been provided for this image
Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 1 - 40 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 1.00
- Lower transition bandwidth: 1.00 Hz (-6 dB cutoff frequency: 0.50 Hz)
- Upper passband edge: 40.00 Hz
- Upper transition bandwidth: 10.00 Hz (-6 dB cutoff frequency: 45.00 Hz)
- Filter length: 845 samples (3.301 s)

Filtering raw data in 1 contiguous segment
Setting up band-stop filter from 49 - 51 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandstop filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 49.38
- Lower transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 49.12 Hz)
- Upper passband edge: 50.62 Hz
- Upper transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 50.88 Hz)
- Filter length: 1691 samples (6.605 s)

No description has been provided for this image
Using annotations from: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-019/ses-01/eeg/sub-019_ses-01_task-szMonitoring_run-02_events.tsv
Not setting metadata
920 matching events found
Setting baseline interval to [-0.19921875, 0.0] s
Applying baseline correction (mode: mean)
0 projection items activated
Using data from preloaded Raw for 920 events and 257 original time points ...
1 bad epochs dropped
Created 919 epochs for sub-019_ses-01_task-szMonitoring_run-02_eeg.edf
Processing EDF file: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-019/ses-01/eeg/sub-019_ses-01_task-szMonitoring_run-03_eeg.edf
Extracting EDF parameters from /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-019/ses-01/eeg/sub-019_ses-01_task-szMonitoring_run-03_eeg.edf...
EDF file detected
Setting channel info structure...
Creating raw.info structure...
Reading 0 ... 19638015  =      0.000 ... 76710.996 secs...
/var/folders/s6/5tcrcv3n2mb5m18jfn2czp_r0000gn/T/ipykernel_5102/1141197103.py:54: RuntimeWarning: The events passed to the Epochs constructor are not chronologically ordered.
  epochs = mne.Epochs(raw, events, event_id, tmin, tmax, baseline=(None, 0), preload=True,
No description has been provided for this image
Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 1 - 40 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 1.00
- Lower transition bandwidth: 1.00 Hz (-6 dB cutoff frequency: 0.50 Hz)
- Upper passband edge: 40.00 Hz
- Upper transition bandwidth: 10.00 Hz (-6 dB cutoff frequency: 45.00 Hz)
- Filter length: 845 samples (3.301 s)

Filtering raw data in 1 contiguous segment
Setting up band-stop filter from 49 - 51 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandstop filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 49.38
- Lower transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 49.12 Hz)
- Upper passband edge: 50.62 Hz
- Upper transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 50.88 Hz)
- Filter length: 1691 samples (6.605 s)

No description has been provided for this image
Using annotations from: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-019/ses-01/eeg/sub-019_ses-01_task-szMonitoring_run-03_events.tsv
Multiple event values for single event times found. Keeping the first occurrence and dropping all others.
Not setting metadata
7671 matching events found
Setting baseline interval to [-0.19921875, 0.0] s
Applying baseline correction (mode: mean)
0 projection items activated
Using data from preloaded Raw for 7671 events and 257 original time points ...
1 bad epochs dropped
Created 7670 epochs for sub-019_ses-01_task-szMonitoring_run-03_eeg.edf
Processing EDF file: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-019/ses-01/eeg/sub-019_ses-01_task-szMonitoring_run-06_eeg.edf
Extracting EDF parameters from /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-019/ses-01/eeg/sub-019_ses-01_task-szMonitoring_run-06_eeg.edf...
EDF file detected
Setting channel info structure...
Creating raw.info structure...
Reading 0 ... 6216447  =      0.000 ... 24282.996 secs...
No description has been provided for this image
Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 1 - 40 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 1.00
- Lower transition bandwidth: 1.00 Hz (-6 dB cutoff frequency: 0.50 Hz)
- Upper passband edge: 40.00 Hz
- Upper transition bandwidth: 10.00 Hz (-6 dB cutoff frequency: 45.00 Hz)
- Filter length: 845 samples (3.301 s)

Filtering raw data in 1 contiguous segment
Setting up band-stop filter from 49 - 51 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandstop filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 49.38
- Lower transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 49.12 Hz)
- Upper passband edge: 50.62 Hz
- Upper transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 50.88 Hz)
- Filter length: 1691 samples (6.605 s)

No description has been provided for this image
Using annotations from: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-019/ses-01/eeg/sub-019_ses-01_task-szMonitoring_run-06_events.tsv
Multiple event values for single event times found. Keeping the first occurrence and dropping all others.
Not setting metadata
2428 matching events found
Setting baseline interval to [-0.19921875, 0.0] s
Applying baseline correction (mode: mean)
0 projection items activated
Using data from preloaded Raw for 2428 events and 257 original time points ...
1 bad epochs dropped
Created 2427 epochs for sub-019_ses-01_task-szMonitoring_run-06_eeg.edf
Processing EDF file: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-019/ses-01/eeg/sub-019_ses-01_task-szMonitoring_run-07_eeg.edf
Extracting EDF parameters from /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-019/ses-01/eeg/sub-019_ses-01_task-szMonitoring_run-07_eeg.edf...
EDF file detected
Setting channel info structure...
Creating raw.info structure...
Reading 0 ... 20275711  =      0.000 ... 79201.996 secs...
No description has been provided for this image
Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 1 - 40 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 1.00
- Lower transition bandwidth: 1.00 Hz (-6 dB cutoff frequency: 0.50 Hz)
- Upper passband edge: 40.00 Hz
- Upper transition bandwidth: 10.00 Hz (-6 dB cutoff frequency: 45.00 Hz)
- Filter length: 845 samples (3.301 s)

Filtering raw data in 1 contiguous segment
Setting up band-stop filter from 49 - 51 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandstop filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 49.38
- Lower transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 49.12 Hz)
- Upper passband edge: 50.62 Hz
- Upper transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 50.88 Hz)
- Filter length: 1691 samples (6.605 s)

No description has been provided for this image
Using annotations from: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-019/ses-01/eeg/sub-019_ses-01_task-szMonitoring_run-07_events.tsv
Not setting metadata
7923 matching events found
Setting baseline interval to [-0.19921875, 0.0] s
Applying baseline correction (mode: mean)
0 projection items activated
Using data from preloaded Raw for 7923 events and 257 original time points ...
/var/folders/s6/5tcrcv3n2mb5m18jfn2czp_r0000gn/T/ipykernel_5102/1141197103.py:54: RuntimeWarning: The events passed to the Epochs constructor are not chronologically ordered.
  epochs = mne.Epochs(raw, events, event_id, tmin, tmax, baseline=(None, 0), preload=True,
1 bad epochs dropped
Created 7922 epochs for sub-019_ses-01_task-szMonitoring_run-07_eeg.edf
Processing EDF file: /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-019/ses-01/eeg/sub-019_ses-01_task-szMonitoring_run-05_eeg.edf
Extracting EDF parameters from /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-019/ses-01/eeg/sub-019_ses-01_task-szMonitoring_run-05_eeg.edf...
EDF file detected
Setting channel info structure...
Creating raw.info structure...
Reading 0 ... 20177151  =      0.000 ... 78816.996 secs...
No description has been provided for this image
Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 1 - 40 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 1.00
- Lower transition bandwidth: 1.00 Hz (-6 dB cutoff frequency: 0.50 Hz)
- Upper passband edge: 40.00 Hz
- Upper transition bandwidth: 10.00 Hz (-6 dB cutoff frequency: 45.00 Hz)
- Filter length: 845 samples (3.301 s)

---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
Cell In[21], line 77
     74 raw.plot(n_channels=n_channels_total, duration=10, title=f'Raw EEG Data: {os.path.basename(edf_file)}')
     76 # Preprocess: Filter (1-40 Hz) and Notch Filter (50 Hz)
---> 77 raw_filtered = raw.copy().filter(l_freq=1, h_freq=40, method='fir', fir_window='hamming')
     78 raw_filtered.notch_filter(freqs=[50])
     79 raw_filtered.plot(n_channels=n_channels_total, duration=10, title=f'Filtered EEG Data: {os.path.basename(edf_file)}')

File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/mne/io/base.py:1174, in BaseRaw.filter(self, l_freq, h_freq, picks, filter_length, l_trans_bandwidth, h_trans_bandwidth, n_jobs, method, iir_params, phase, fir_window, fir_design, skip_by_annotation, pad, verbose)
   1155 @copy_doc(FilterMixin.filter)
   1156 def filter(
   1157     self,
   (...)
   1172     verbose=None,
   1173 ):
-> 1174     return super().filter(
   1175         l_freq,
   1176         h_freq,
   1177         picks,
   1178         filter_length,
   1179         l_trans_bandwidth,
   1180         h_trans_bandwidth,
   1181         n_jobs=n_jobs,
   1182         method=method,
   1183         iir_params=iir_params,
   1184         phase=phase,
   1185         fir_window=fir_window,
   1186         fir_design=fir_design,
   1187         skip_by_annotation=skip_by_annotation,
   1188         pad=pad,
   1189         verbose=verbose,
   1190     )

File <decorator-gen-98>:12, in filter(self, l_freq, h_freq, picks, filter_length, l_trans_bandwidth, h_trans_bandwidth, n_jobs, method, iir_params, phase, fir_window, fir_design, skip_by_annotation, pad, verbose)

File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/mne/filter.py:2562, in FilterMixin.filter(self, l_freq, h_freq, picks, filter_length, l_trans_bandwidth, h_trans_bandwidth, n_jobs, method, iir_params, phase, fir_window, fir_design, skip_by_annotation, pad, verbose)
   2558 for si, (start, stop) in enumerate(zip(onsets, ends)):
   2559     # Only output filter params once (for info level), and only warn
   2560     # once about the length criterion (longest segment is too short)
   2561     use_verbose = verbose if si == max_idx else "error"
-> 2562     filter_data(
   2563         self._data[:, start:stop],
   2564         s_freq,
   2565         l_freq,
   2566         h_freq,
   2567         picks,
   2568         filter_length,
   2569         l_trans_bandwidth,
   2570         h_trans_bandwidth,
   2571         n_jobs,
   2572         method,
   2573         iir_params,
   2574         copy=False,
   2575         phase=phase,
   2576         fir_window=fir_window,
   2577         fir_design=fir_design,
   2578         pad=pad,
   2579         verbose=use_verbose,
   2580     )
   2581 # update info if filter is applied to all data channels/vertices,
   2582 # and it's not a band-stop filter
   2583 if not isinstance(self, _BaseSourceEstimate):

File <decorator-gen-93>:12, in filter_data(data, sfreq, l_freq, h_freq, picks, filter_length, l_trans_bandwidth, h_trans_bandwidth, n_jobs, method, iir_params, copy, phase, fir_window, fir_design, pad, verbose)

File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/mne/filter.py:1027, in filter_data(data, sfreq, l_freq, h_freq, picks, filter_length, l_trans_bandwidth, h_trans_bandwidth, n_jobs, method, iir_params, copy, phase, fir_window, fir_design, pad, verbose)
   1012 filt = create_filter(
   1013     data,
   1014     sfreq,
   (...)
   1024     fir_design,
   1025 )
   1026 if method in ("fir", "fft"):
-> 1027     data = _overlap_add_filter(data, filt, None, phase, picks, n_jobs, copy, pad)
   1028 else:
   1029     data = _iir_filter(data, filt, picks, n_jobs, copy, phase)

File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/mne/filter.py:346, in _overlap_add_filter(x, h, n_fft, phase, picks, n_jobs, copy, pad)
    342         x[p] = _1d_overlap_filter(
    343             x[p], len(h), n_edge, phase, cuda_dict, pad, n_fft
    344         )
    345 else:
--> 346     data_new = parallel(
    347         p_fun(x[p], len(h), n_edge, phase, cuda_dict, pad, n_fft) for p in picks
    348     )
    349     for pp, p in enumerate(picks):
    350         x[p] = data_new[pp]

File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/joblib/parallel.py:1863, in Parallel.__call__(self, iterable)
   1861     output = self._get_sequential_output(iterable)
   1862     next(output)
-> 1863     return output if self.return_generator else list(output)
   1865 # Let's create an ID that uniquely identifies the current call. If the
   1866 # call is interrupted early and that the same instance is immediately
   1867 # re-used, this id will be used to prevent workers that were
   1868 # concurrently finalizing a task from the previous call to run the
   1869 # callback.
   1870 with self._lock:

File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/joblib/parallel.py:1792, in Parallel._get_sequential_output(self, iterable)
   1790 self.n_dispatched_batches += 1
   1791 self.n_dispatched_tasks += 1
-> 1792 res = func(*args, **kwargs)
   1793 self.n_completed_tasks += 1
   1794 self.print_progress()

File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/mne/parallel.py:127, in parallel_func.<locals>.run_verbose(verbose, *args, **kwargs)
    125 def run_verbose(*args, verbose=logger.level, **kwargs):
    126     with use_log_level(verbose=verbose):
--> 127         return func(*args, **kwargs)

File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/mne/filter.py:373, in _1d_overlap_filter(x, n_h, n_edge, phase, cuda_dict, pad, n_fft)
    371 stop = (seg_idx + 1) * n_seg
    372 seg = x_ext[start:stop]
--> 373 seg = np.concatenate([seg, np.zeros(n_fft - len(seg))])
    375 prod = _fft_multiply_repeated(seg, cuda_dict)
    377 start_filt = max(0, start - shift)

KeyboardInterrupt: 
InĀ [Ā ]:
raw_filtered = raw.copy()
raw_filtered.filter(l_freq=1, h_freq=40, method='fir', fir_window='hamming')
Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 1 - 40 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 1.00
- Lower transition bandwidth: 1.00 Hz (-6 dB cutoff frequency: 0.50 Hz)
- Upper passband edge: 40.00 Hz
- Upper transition bandwidth: 10.00 Hz (-6 dB cutoff frequency: 45.00 Hz)
- Filter length: 845 samples (3.301 s)

Out[Ā ]:
General
Filename(s) sub-021_ses-01_task-szMonitoring_run-09_eeg.edf
MNE object type RawEDF
Measurement date 2000-01-01 at 00:00:00 UTC
Participant x
Experimenter Unknown
Acquisition
Duration 20:51:26 (HH:MM:SS)
Sampling frequency 256.00 Hz
Time points 19,222,016
Channels
EEG
Head & sensor digitization Not available
Filters
Highpass 1.00 Hz
Lowpass 40.00 Hz
InĀ [15]:
raw_filtered.notch_filter(freqs=[50])
raw_filtered.plot(n_channels=2, duration=10, title='Filtered EEG Data (1-40 Hz, Notch 50 Hz)')
Filtering raw data in 1 contiguous segment
Setting up band-stop filter from 49 - 51 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandstop filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 49.38
- Lower transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 49.12 Hz)
- Upper passband edge: 50.62 Hz
- Upper transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 50.88 Hz)
- Filter length: 1691 samples (6.605 s)

No description has been provided for this image
Out[15]:
No description has been provided for this image
InĀ [19]:
def load_all_annotations(filepaths):
    annotations_list = []
    for fp in filepaths:
        ann = pd.read_csv(fp, sep='\t')
        ann['source_file'] = os.path.basename(fp)
        annotations_list.append(ann)
    if annotations_list:
        return pd.concat(annotations_list, ignore_index=True)
    else:
        return pd.DataFrame()  # empty if no files found

all_tsv_files = glob.glob(os.path.join(data_path, "**", "*_events.tsv"), recursive=True)
print(f"Found {len(all_tsv_files)} TSV files total.")
annotations_df = load_all_annotations(all_tsv_files)

# --- Count Seizure and Non-Seizure Events ---
# Here we assume that every row in your TSV is a seizure event.
# If your file includes a column (e.g., "event" or "label") to distinguish, adjust accordingly.
seizure_count = len(annotations_df)
print(f"Seizure events (from annotations): {seizure_count}")

# If your TSV has a column indicating event type, for example:
# seizure_count = (annotations_df['event'] == 'seizure').sum()
# non_seizure_count = (annotations_df['event'] == 'non-seizure').sum()
# print(f"Seizure events: {seizure_count}, Non-seizure events: {non_seizure_count}")

# --- Create Epochs for a Given Raw Data and Its Annotations ---
def create_epochs(raw, annotations, tmin=-0.2, tmax=0.8):
    events = []
    event_id = {'seizure': 1, 'non-seizure': 0}
    
    # Add seizure events from the annotations
    for _, row in annotations.iterrows():
        onset = row['onset']
        events.append([int(onset * raw.info['sfreq']), 0, event_id['seizure']])
    
    # Add non-seizure events with fixed-length epochs (e.g., every 10 seconds)
    non_seizure_events = mne.make_fixed_length_events(raw, id=event_id['non-seizure'], duration=10)
    events.extend(non_seizure_events)
    
    events = np.array(events)
    epochs = mne.Epochs(raw, events, event_id, tmin, tmax, baseline=(None, 0), preload=True)
    return epochs

# --- Process All EDF Files in the Dataset ---
all_edf_files = glob.glob(os.path.join(data_path, "**", "*_eeg.edf"), recursive=True)
print(f"Found {len(all_edf_files)} EDF files total.")

epochs_list = []
for edf_file in all_edf_files:
    # Load raw EEG data
    raw = mne.io.read_raw_edf(edf_file, preload=True)
    
    # Optionally, preprocess your raw data here (e.g., filtering, notch filtering, etc.)
    raw.filter(l_freq=1, h_freq=40, method='fir', fir_window='hamming')
    raw.notch_filter(freqs=[50])
    
    # Find the corresponding TSV file using part of the file name
    base_name = os.path.basename(edf_file).replace('_eeg.edf', '')
    matching_tsv = [fp for fp in all_tsv_files if base_name in fp]
    
    if matching_tsv:
        annotations = pd.read_csv(matching_tsv[0], sep='\t')
    else:
        print(f"No matching TSV found for {edf_file}. Skipping seizure events for this file.")
        annotations = pd.DataFrame()  # No seizure events available
    
    epochs = create_epochs(raw, annotations)
    epochs_list.append(epochs)

# Optionally, combine epochs from all files into one object (if they have the same channel layout)
if epochs_list:
    all_epochs = mne.concatenate_epochs(epochs_list)
    print("Total epochs created:", len(all_epochs.events))
else:
    print("No epochs were created.")
Found 2853 TSV files total.
Seizure events (from annotations): 3664
Found 2853 EDF files total.
Extracting EDF parameters from /Users/jananjahed/Desktop/Bachelor's project/ds005873/sub-021/ses-01/eeg/sub-021_ses-01_task-szMonitoring_run-09_eeg.edf...
EDF file detected
Setting channel info structure...
Creating raw.info structure...
Reading 0 ... 19222015  =      0.000 ... 75085.996 secs...
Filtering raw data in 1 contiguous segment
Setting up band-pass filter from 1 - 40 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandpass filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 1.00
- Lower transition bandwidth: 1.00 Hz (-6 dB cutoff frequency: 0.50 Hz)
- Upper passband edge: 40.00 Hz
- Upper transition bandwidth: 10.00 Hz (-6 dB cutoff frequency: 45.00 Hz)
- Filter length: 845 samples (3.301 s)

Filtering raw data in 1 contiguous segment
Setting up band-stop filter from 49 - 51 Hz

FIR filter parameters
---------------------
Designing a one-pass, zero-phase, non-causal bandstop filter:
- Windowed time-domain design (firwin) method
- Hamming window with 0.0194 passband ripple and 53 dB stopband attenuation
- Lower passband edge: 49.38
- Lower transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 49.12 Hz)
- Upper passband edge: 50.62 Hz
- Upper transition bandwidth: 0.50 Hz (-6 dB cutoff frequency: 50.88 Hz)
- Filter length: 1691 samples (6.605 s)

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Cell In[19], line 68
     65         print(f"No matching TSV found for {edf_file}. Skipping seizure events for this file.")
     66         annotations = pd.DataFrame()  # No seizure events available
---> 68     epochs = create_epochs(raw, annotations)
     69     epochs_list.append(epochs)
     71 # Optionally, combine epochs from all files into one object (if they have the same channel layout)

Cell In[19], line 42, in create_epochs(raw, annotations, tmin, tmax)
     39 events.extend(non_seizure_events)
     41 events = np.array(events)
---> 42 epochs = mne.Epochs(raw, events, event_id, tmin, tmax, baseline=(None, 0), preload=True)
     43 return epochs

File <decorator-gen-228>:12, in __init__(self, raw, events, event_id, tmin, tmax, baseline, picks, preload, reject, flat, proj, decim, reject_tmin, reject_tmax, detrend, on_missing, reject_by_annotation, metadata, event_repeated, verbose)

File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/mne/epochs.py:3580, in Epochs.__init__(self, raw, events, event_id, tmin, tmax, baseline, picks, preload, reject, flat, proj, decim, reject_tmin, reject_tmax, detrend, on_missing, reject_by_annotation, metadata, event_repeated, verbose)
   3575     events, event_id, annotations = _events_from_annotations(
   3576         raw, events, event_id, annotations, on_missing
   3577     )
   3579 # call BaseEpochs constructor
-> 3580 super().__init__(
   3581     info,
   3582     None,
   3583     events,
   3584     event_id,
   3585     tmin,
   3586     tmax,
   3587     metadata=metadata,
   3588     baseline=baseline,
   3589     raw=raw,
   3590     picks=picks,
   3591     reject=reject,
   3592     flat=flat,
   3593     decim=decim,
   3594     reject_tmin=reject_tmin,
   3595     reject_tmax=reject_tmax,
   3596     detrend=detrend,
   3597     proj=proj,
   3598     on_missing=on_missing,
   3599     preload_at_end=preload,
   3600     event_repeated=event_repeated,
   3601     verbose=verbose,
   3602     raw_sfreq=raw_sfreq,
   3603     annotations=annotations,
   3604 )

File <decorator-gen-212>:12, in __init__(self, info, data, events, event_id, tmin, tmax, baseline, raw, picks, reject, flat, decim, reject_tmin, reject_tmax, detrend, proj, on_missing, preload_at_end, selection, drop_log, filename, metadata, event_repeated, raw_sfreq, annotations, verbose)

File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/mne/epochs.py:529, in BaseEpochs.__init__(***failed resolving arguments***)
    520     self.drop_log = drop_log
    522 self.events = self.events[selected]
    524 (
    525     self.events,
    526     self.event_id,
    527     self.selection,
    528     self.drop_log,
--> 529 ) = _handle_event_repeated(
    530     self.events,
    531     self.event_id,
    532     event_repeated,
    533     self.selection,
    534     self.drop_log,
    535 )
    537 # then subselect
    538 sub = np.where(np.isin(selection, self.selection))[0]

File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/mne/epochs.py:330, in _handle_event_repeated(events, event_id, event_repeated, selection, drop_log)
    328 drop_log = list(drop_log)
    329 if event_repeated == "error":
--> 330     raise RuntimeError(
    331         "Event time samples were not unique. Consider "
    332         'setting the `event_repeated` parameter."'
    333     )
    335 elif event_repeated == "drop":
    336     logger.info(
    337         "Multiple event values for single event times found. "
    338         "Keeping the first occurrence and dropping all others."
    339     )

RuntimeError: Event time samples were not unique. Consider setting the `event_repeated` parameter."